package com.example.class1;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class ConfigActivity extends AppCompatActivity {

private static final String TAG="config";
EditText dollarText,euroText,wonText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config);
        Intent intent =getIntent();
        float dollar2=intent.getFloatExtra("dollar_rate_key",0.0f);
        float euro2=intent.getFloatExtra("euro_rate_key",0.0f);
        float won2=intent.getFloatExtra("won_rate_key",0.0f);
        Log.i(TAG,"onCreate:dollar="+dollar2);
        Log.i(TAG,"onCreate:euro="+euro2);
        Log.i(TAG,"onCreate:won="+won2);
        dollarText=(EditText) findViewById(R.id.rate_dollar);
        EditText new_euro=findViewById(R.id.rate_euro);
        EditText new_won=findViewById(R.id.rate_won);

        dollarText.setText(String.valueOf(dollar2));
        euroText.setText(String.valueOf(euro2));
        wonText.setText(String.valueOf(won2));
    }
    public void save(View btn){

        Log.i(TAG,"save:");

        float newDollar=Float.parseFloat(dollarText.getText().toString());
        float newEuro=Float.parseFloat(euroText.getText().toString());
        float newWon=Float.parseFloat(wonText.getText().toString());
        Log.i(TAG,"save:获取到新的值");
        Log.i(TAG,"onCreat:newDollar="+newDollar);
        Log.i(TAG,"onCreat:newEuro="+newEuro);
        Log.i(TAG,"onCreat:newWon="+newWon);

        Intent intent=getIntent();
        Bundle bd1=new Bundle();
        bd1.putFloat("key_dollar",newDollar);
        bd1.putFloat("key_euro",newEuro);
        bd1.putFloat("key_won",newWon);
        intent.putExtras(bd1);
        setResult(2,intent);
        finish();


    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {

        super.onActivityResult(requestCode, resultCode, data);
    }


}




